package com.cloudkinto.bo.order;

import com.cloudkinto.bo.common.BaseQueryBo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * 用于封装yahoo订单查询条件
 *
 * @author long
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class OrderYahooQueryBo extends BaseQueryBo {

    @ApiModelProperty("是否转发货")
    private Integer isSend;

    @ApiModelProperty("订单状态1 : 予約中2 : 処理中 3 : 保留 4 : キャンセル 5 :  完了")
    private String orderStatus;

    @ApiModelProperty("店铺id")
    private String shopId;

    @ApiModelProperty("时间")
    private String dateStart;

    @ApiModelProperty("时间")
    private String dateEnd;

    @ApiModelProperty("时间类型")
    private String dateType;

    @ApiModelProperty("支付状态")
    private String payStatus;

    @ApiModelProperty("发货状态")
    private String shipStatus;

    @ApiModelProperty("订单id")
    private String orderId;

    @ApiModelProperty("收货人")
    private String shipFirstName;

    @ApiModelProperty("收货人")
    private String shipLastName;

    @ApiModelProperty("备注")
    private String systemMemo;

    @ApiModelProperty("收货人电话")
    private String shipPhone;

    public Date getDateStart() {
        if (StringUtils.isBlank(dateStart)){
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(dateStart, format).atTime(0,0,0);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
    public Date getDateEnd() {
        if (StringUtils.isBlank(dateEnd)){
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(dateEnd, format).atTime(23,59,59);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
}
